package arithmetic.LeetCode;

import java.util.Arrays;

/**
 * https://leetcode.cn/problems/minimize-maximum-pair-sum-in-array/solution/
 * 数组中最大数对和的最小值
 * @author jiangfeng on 2023/4/7
 */
public class FindMinSum {
    public int minPairSum(int[] nums) {
        //
        Arrays.sort(nums);
        //find max
        int result = 0;
        for (int i = 0; i < nums.length / 2; i++) {
            result = Math.max(result, (nums[i] + nums[nums.length - 1 - i]));
        }
        return result;
    }
}
